home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / dos_win / winsock / maillist / 94-04.Z / 94-04 / text0303.txt < prev    next >
Encoding:
Text File  |  1994-04-30  |  1.2 KB  |  37 lines

  1. Winsock users,
  2.  
  3.  I have a routine that receives a string, creates a TCP socket, connects it
  4.  to a server and sends the string through the connection. The eculiar thing
  5.  is that at certain times the socket() call returns a descriptor = 0 which
  6.  apparently is not flagged as an INVALID socket. However on attempting to
  7.  send() over a connection through this socket a "descritor not a socket"
  8.  error occurs. The code I am using is as shown below. I am using a
  9.  sockets implementation from sun.
  10.  
  11.      Any suggestions will be highly appreciated.
  12.  
  13.          Please reply via e-mail tw46555@is1.vub.ac.be
  14.  
  15.  
  16.        if((s = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {
  17.           sockerror();
  18.           MessageBox(GetActiveWindow(),"Socket open error.\n", "ERROR", MB_ICONSTOP | MB_OK);
  19.          return(entries);
  20.        }
  21.        if(connect(s,(LPSOCKADDR)&sa,sizeof(sa)) == SOCKET_ERROR){
  22.         sockerror();
  23.         MessageBox(GetActiveWindow(),"Socket connect error.\n", "ERROR", MB_ICONSTOP | MB_OK);
  24.          return (entries);
  25.        }
  26.         
  27.        if(send(s,(LPSTR)params,lstrlen((LPCSTR)params),0) == SOCKET_ERROR){      // call server
  28.           sockerror();
  29.           return (entries);
  30.        }
  31.  
  32.  
  33.  
  34. Thank you in advance.
  35.             Muraya.
  36.  
  37.